package com.deshan.websys.api.config;

import com.deshan.websys.code.utils.ApplicationUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String savepath="D:/workspace/shande-backend-code/nacos/data/upload/";
        try{
            savepath= ApplicationUtils.getProperty("oss.savepath", "C:/shande-backend-code/nacos/data/upload/");
        }catch (Exception ex){

        }
        //其中image表示访问的前缀。"file:E:/upload/"是文件真实的存储路径
        registry.addResourceHandler("/api/upload/**").addResourceLocations("file:"+savepath);
    }
}
